
import math


class Vector:
    def __init__(self,x,y):
        self.x =x
        self.y =y
    def __repr__(self):
        return f"Vector({self.x},{self.y})"
    def __add__(self,other):
        if isinstance(other,Vector):
            return Vector(self.x + other.x,self.y + other.y)
        else:
            raise TypeError("Unsupported operand type. Addition only supported between two Vector objects.")
    def __abs__(self):
        return math.hypot(self.x,self.y)
        #squared_sum = self.x ** 2 + self.y ** 2
        #return math.sqrt(squared_sum)
    def __mul__(self,scalar):
        if isinstance(scalar, (int, float)):
            return Vector(self.x * scalar, self.y * scalar)
        else:
            raise TypeError("Unsupported operand type. Multiplication only supported between a Vector and a scalar value.")
    def __bool__(self):
        return bool(abs(self))
v1 = Vector(3,4)
v2 = Vector(2,1)
print(v1+v2)
print(abs(v1))
print(v1 * 3)
print(abs(v1) * 3)
print(bool(v1))

